# Compactness
Compactness is a key topological property. Roughly speaking, it generalizes "finiteness" without being necessarily discrete, giving "closedness" and "boundedness".
## Topological definition.
First we give its topological definition.
> (T) A subset $K$ of a topological space $X$ is compact if for every open cover of $K$, there exists a finite subcover.
That is to say, $K$ is compact if whenever $\{U_{\lambda}\}_{\lambda \in \Lambda}$ is an open cover of $K$, namely each $U_{\lambda}$ is an open set and $K\subset \bigcup_{\lambda\in \Lambda} U_{\lambda }$, then one can find a finite subcollection $S\subset\Lambda$, $|S| < \infty$, where $K \subset \bigcup_{\lambda \in S} U_{\lambda}$.
**Example**. Any finite subset is compact. The set of all positive integers $\mathbf{N}$ in the usual real line $\mathbf{R}$ is not compact. The set $A =\{1 / n :n \in \mathbf{N}\}$ in the usual real line is not compact, but $B =\{0\}\cup\{1 /n:n \in \mathbf{N}\}$ is compact.
Indeed, one can consider the open cover $\{I_{n}\}_{n\in \mathbf{N}}$ for $A$, where $I_{n} = \left( \frac{1}{n+1}, \frac{1}{n-1} \right)$ for $n\ge 2$ and $I_{1} = (\frac{1}{2},2)$. Note each point in $A$ is contained in one and exactly one open interval $I_{n}$. Hence no finite subcollection of $I_n$ can cover $A$. Thus $A$ is not compact.
However, if introduced the point $0$ as well to $A$, forming the set $B$, then for any open cover of $B$, there exists some open element $U_{0}$ that contains $0$, which would also contain an infinite tail of elements of the form $\frac{1}{n}$ for $n \ge M$, some $M$. Then the remaining points can be captured with finitely many open sets from this open cover. Hence $B$ is compact.
A useful lemma.
> Closed sets in a compact set is compact.
Suppose $X$ is some topological space, and $K\subset X$ is compact. Suppose further that $F\subset X$ is a closed set with $F \subset K$. Let $\{U_{\lambda}\}_{\lambda\in \Lambda}$ be an open cover of $F$. Note then $\{U_{\lambda}\}_{\lambda\in \Lambda} \cup \{F^{c}\}$ is an open cover for compact set $K$. Then we have finite subcovering $U_{\lambda_{1}}\cup\cdots\cup U_{\lambda_{m}}\cup F^{c}$ for $K$. Note then $U_{\lambda_{1}}\cup\cdots\cup U_{\lambda_{m}}$ covers $F$. Whence $F$ is compact. $\blacksquare$
## Special case in Euclidean spaces - Heine-Borel theorem.
We give a characterization of compact subsets in usual Euclidean spaces $\mathbf{R}^{n}$.
> Heine-Borel.
> Let $K$ be a subset of the usual Euclidean space $\mathbf{R}^{n}$. Then $K$ is compact if and only if $K$ is closed and bounded.
We establish a few basic lemmas.
> If $K$ is a compact subset in a metric space $X$, then $K$ is closed and bounded.
Suppose $K \subset X$ is compact.
We show $K$ is bounded. Indeed, consider the open cover of radius $1$ open balls with center at each point in $K$. Then there exists a finite subcovering, say with $m$ many unit radius balls at centers $x_{1},x_{2},\ldots,x_{m}$. Then the set $K$ is contained in the ball $B(0, 1 + \max|x_{i}|)$, hence $K$ bounded.
We show $K$ is closed. Suppose to the contrary that $K$ is not closed. Then there exists some adherent point $p$ of $K$ where $p \not\in K$. Then for each $x \in K$, we can produce a pair of disjoint open balls, $U_{x}\ni x$ and $V_{x}\ni p$ with $U_{x}\cap V_{x} = \varnothing$. This is possible because $X$ is a metric space (and thusly Hausdorff). The collection $\{U_{x}\}_{x \in K}$ forms an open cover for $K$, and as $K$ is compact, we have finite subcover $U_{x_{1}}\cup U_{x_{2}}\cup \cdots \cup U_{x_{m}} \supset K$, some $m$. But the intersection $V_{x_{1}}\cap V_{x_{2}}\cap \cdots \cap V_{x_{m}}$ is an open neighborhood about $p$ that avoids each of the $U_{x_{i}}$, and hence avoiding $K$. This contradicts that $p$ is an adherent point of $K$! Hence $K$ is closed.
**Remark**. If $K$ is compact in an arbitrary topological space, it need not be closed! Indeed, consider the two point space $X = \{a,b\}$ with the coarse topology, so the only open sets are $\varnothing$ and $X$. Then the singleton set $\{a\}$ is compact, but it is not closed! And there's no natural notion of boundedness in a topological space, so these properties are really for metric spaces.
**Remark**. However, not every closed and bounded set in a metric space is compact! Indeed, consider any infinite set $X$ and impose the discrete metric on $X$, where $d(x,y)=1$ if $x \neq y$. Then $X$ is itself closed and bounded. However, $X$ is not compact, the open cover $\{B(x, 1/2)\}_{x\in X}$ cannot be refined to a finite subcovering for $X$.
So the fact that in Euclidean spaces, closed and bounded sets would imply compactness is a special property, called Heine-Borel.
It suffices to prove the following
> An $n$-box in $\mathbf{R}^{n}$ is compact.
Suppose some $n$-box $I=I_{0}$ has an open cover $\{U_{\lambda}\}$ that cannot be refined to a finite subcover. Subdivide each axis by 2 to create $2^{n}$ many $n$-boxes. Then one of them cannot of finitely covered, call it $I_{1}$. Repeat this process. This gives a sequence of nested $n$-boxes $$
I_{0}\supset I_{1} \supset I_{2}\supset \cdots
$$Then as nested $n$-boxes has a common intersection, there exists some $p$ that lives in each $I_{k}$. Since there exists some open set $U_{\lambda}$ from our open cover that contains $p$, we know that there is some open ball around $p$ that fits in $U_{\lambda}$. But as the sides of $I_{k}$ go to zero, there exists some $I_{k}$ such that $p \in I_{k} \in U_{\lambda}$, which means $I_{k}$ is finitely coverable, a contradiction!
This uses the nested interval and nested $n$-box property of Euclidean spaces.
Finally, if we take some closed and bounded subset $K \subset \mathbf{R}^{n}$, then $K \subset I$ for some $n$-box. Since $K$ is a closed set inside a compact set $I$, we have $K$ compact as well. This gives Heine-Borel.
## Sequential formulation in a metric space.
If our space is also a metric space, which we can speak of sequences, then we have an equivalent formulation of compactness called sequential compactness:
> (S) A subset $K$ of a metric space $X$ is sequentially compact if every sequence in $K$ has a convergent subsequence that converges in $K$.
We note some properties of a sequentially compact metric space $K$.
> Lemma. If $K$ is sequentially compact metric space, then $K$ is totally bounded. That is, for every positive $\epsilon > 0$, $K$ can be covered by finitely many open balls of radius $\epsilon$.
Proof. Suppose to the contrary that there exists some $\epsilon > 0$ where $K$ cannot be covered with finitely many open balls of radius $\epsilon$. Then take $x_{1} \in K$, the open ball $B_{1} = B(x_{1},\epsilon)$ does not cover $K$. So there exist some $x_{2}\in K \setminus B_{1}$. Now, the open ball $B_{2}=B(x_{2},\epsilon)$ together with $B_{1}$ also do not cover $K$, so there exists some $x_{3} \in K \setminus (B_{1}\cup B_{2})$. Repeating this process produces a sequence $(x_{n})$ where the pairwise distance $d(x_{n},x_{m}) \ge \epsilon$ for all $n \neq m$. But $K$ is sequentially compact, there exists a convergent subsequence that is not Cauchy, a contradiction! Hence $K$ is totally bounded. $\blacksquare$
> Lemma. If $K$ is a sequentially compact metric space, then $K$ is separable, that is, there exists a countable dense subset in $K$.
Proof. For each positive integer $n \in \mathbf{N}$, as $K$ is totally bounded, one can cover $K$ with finitely many open balls of radius $\frac{1}{n}$, with some finitely many centers $x_{1}^{(n)}, x_{2}^{(n)},\ldots,x_{r(n)}^{(n)}$ in $K$, some $r(n)$. Now consider the countable collection $D = \bigcup_{n=1}^{\infty}\bigcup_{i=1}^{r(n)} \{ x_{i}^{(n)}\}$. We claim $D$ is dense in $K$. Indeed, for any $x\in K$, and any $\epsilon > 0$, take $n$ such that $1 / n < \epsilon$. Then note then open balls $B(x_{i}^{(n)}, 1 /n)$, $i = 1,\ldots,r(n)$, covers $K$. So $x$ is in some ball $B(x_{i}^{(n)} , 1 / n)$. That is, $d(x , x_{i}^{(n)}) < 1 / n < \epsilon$. In other words, $B(x,\epsilon)$ intersects $D$. So $D$ is dense in $K$. $\blacksquare$
And that
> Let $K$ be a subset of a metric space $X$. Then $K$ is compact if and only if $K$ is sequentially compact.
Indeed.
$(\implies)$ Suppose $K$ is compact. Take $(a_{n})$ to be a sequence in $K$. Suppose to the contrary that $(a_{n})$ has no convergent sequence in $K$.
This implies the range of the sequence $(a_{n})$ is infinite, otherwise one would be able to find a convergent subsequence (namely a constant sequence).
Now, fix any $x \in K$. We claim that there exists some open ball $B(x,\epsilon_{x})$ about $x$, some $\epsilon_{x} > 0$, such that the punctured ball $B(x,\epsilon_{x})\setminus\{x\}$ contains no other points from the sequence $(a_{n})$. Since if for every $\epsilon > 0$, the punctured ball $B(x,\epsilon)\setminus\{x\}$ contains some term $a_{n}$ from the sequence, we can keep shrinking $\epsilon$ to produce a convergent subsequence that converges to $x$, which contradicts that there is no convergent subsequence.
So the collection $\{B(x,\epsilon_{x})\}_{x\in K}$ forms an open cover of $K$. And since $K$ is compact, there exists a finite subcover, say $K \subset B(x_{1},\epsilon_{x_{1}}) \cup B(x_{2},\epsilon_{x_{2}}) \cup \cdots \cup B(x_{M},\epsilon_{x_{M}})$. But this finite union contains at most $M$ many points from the sequence $(a_{n})$, which we already established that there are infinitely many distinct elements, hence a contradiction.
Thus, $K$ is also sequentially compact.
$(\impliedby)$ Suppose $K$ is sequentially compact.
## Another characterization in metric space.
Yet another equivalent formulation if $K$ is a subset of a metric space, this attempts to generalize Heine-Borel in Euclidean spaces.
> (C & TB) Let $K$ be a subset of a metric space $X$. Then $K$ is compact if and only if $K$ is complete and totally bounded.